package com.block.common.service.impl;

import com.block.common.service.IAddressInfoService;
import com.block.db.entity.AddressInfo;
import com.block.db.mapper.AddressInfoMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 
 * @since 2022-12-05
 */
@Service
public class AddressInfoServiceImpl extends ServiceImpl<AddressInfoMapper, AddressInfo> implements IAddressInfoService {

    private List<String> provinceList = Arrays.asList("北京市", "上海市", "天津市", "重庆市");

    @Override
    public AddressInfo getAddressInfo(String province, String city){
        if (provinceList.contains(province)){
            city = province;
        }
        return this.baseMapper.getAddressInfoByCity(city);
    }

    @Override
    public AddressInfo getAddressInfoByCode(String codeValue){
        return this.getById(codeValue);
    }

    @Override
    public AddressInfo getAddressInfoByName(String name){
        return this.baseMapper.getAddressInfoByName(name);
    }

    @Override
    public AddressInfo getAddressInfoByAlisaName(String name){
        return this.baseMapper.getAddressInfoAliasByName(name);
    }

}
